<!--//$Id$  -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Step-By-Step of How to build a CIAO application</title>
</head>

<body
 text = "#000000"
 link = "#000fff"
 vLink= "#ff0f0f"
 aLink = "#0000ff"
 bgColor = "#ffffff">

<hr>
<h2>Simple <a href="http://www.dre.vanderbilt.edu/CIAO">CIAO</a> tutorial</h2>
<b>Note:</b>
<UL>
<li><a href="http://www.dre.vanderbilt.edu/cosmic">CoSMIC</a> tools are not used in this tutorial.</li>
<li>This is only a <em>GENERAL</em> way of building up a CIAO application and deploying it with DAnCE. The user could always change the process in his own way. For example: the IDL file content, the project structure etc.</li>
<li>To download the code of this example please refer to the CVS repository at <code>$CIAO_ROOT/DAnCE/examples/Hello</code>.</li>
</UL>
<hr>

<h2>Example Description</h2>
This Hello example is contructed in the following ways:
<UL>
<li>1. There are 2 components in the system: Sender and Receiver</li>
<li>2. The Sender will send out the timeout event to the Receiver.</li>
<li>3. Upon receiving the timeout event, the Receiver will go and fetch data from the Sender. </li>
<li>4. The user could deploy multiple instances of the Receiver without changing any C++/idl source code.</li>
</UL>
<hr>

<h2>Step-By-Step</h2>
<h3>Hello_Base</h3>

<OL>
<li>Write an IDL file (<code>Hello_Base.idl</code>) which contains all
    the interfaces and events common to all the components. The reason
    we do this is becuse the generated lib of this idl file will be
    linked in by all the components in the system. To reduce the size
    of the component lib we have to include only the necesary part. In
    this example, we have an eventtype <code>timeout</code> and an
    interface <code>ReadMessage</code>, which are used by both the
    Sender and the Receiver, so we put both of them in Hello.idl.</li>
    <P>
    
<li>Look at the <code>Hello_Base.mpc</code> file to get an idea how the Hello_Base_stub and Hello_Base_svnt projects are organized. <a href="http://downloads.ociweb.com/MPC/MakeProjectCreator.pdf">MPC</a> is a utility we used to generate makefiles or VC project/solution files for all <a href="http://www.cs.wustl.edu/~schmidt/ACE.html">ACE</a>, <a href="http://www.cs.wustl.edu/~schmidt/TAO.html">TAO</a> and <a href="http://www.cs.wustl.edu/~schmidt/CIAO.html">CIAO</a> libraries.</li>
</Ol>

<hr>

<h3>For Every Components</h3>

<ol>
<li>Use: <br>

<code>$CIAO_ROOT/bin/generate_component_mpc.pl -p Hello_Base Sender <br>
      $CIAO_ROOT/bin/generate_component_mpc.pl -p Hello_Base Receiver
</code><br></ul>
Note:
<ul>
<li>I have different directories for <code>"Hello_Base", "Sender", "Receiver"</code> respectively.</li>

<li>For every <code>_stub</code> project, add:<br>
  <code>"libs  += Hello_Base_DnC_stub"</code><br>

</ul><P>

<li>Use the export script to generate the export files. (3 files per
    component).</li> <P>

<li>Write an idl file for every compoent. Here you can put the
    component specific IDL definitions in this file. In this example
    we have a interface <code>trigger</code> specific to the
    Sender. Please note that the Sender component
    <code>"supports"</code> (IDL keyword) this interface. </li> <P>

<li>Write the CIDL file for every component.</li> <P>

<li>Write <code>_exec.h</code> and <code>_exec.cpp</code> files which actually implement the component.</li>
<P>
</OL>

Writing all those files could be troublesome to a new CCM user. The
best way of learning this is to read the example source code. If you
are familliar with CORBA programming, it should not take too much time
before you can declare yourself as a CCM programmer. <P>

<hr> <P>

<h3>The Entry Point</h3>

After both components are implemented we still need a small program to
initialize the process. In Sender.idl there is a Sender specific
interface with a single method in it created for this purpose. Hence
there is a CORBA client application called <code>starter</code>. The
<code>starter</code> will make a invocation on a supported interface
called <code>trigger</code> on the Sender component to get the whole
distributed application started. The <code>starter</code> will first
obtain the Sender component object reference through the ior string
supplied as a command argument. Please see the the last part of
<code>Hello/Sender/Sender.mpc</code> file for details. <P>

<hr>

<h3>Make</h3>

<UL>
<li>Go to the directory <code>$CIAO_ROOT/DAnCE</code> and do:<br>
    <code>$ACE_ROOT/bin/mwc.pl</code> (use -type option if you are using a compiler/IDE other than gnuace -which by default generates GNU makefiles)</li>
    <br>For example, using <code>$ACE_ROOT/bin/mwc.pl -type vc71</code> if you are using Visual C++ 7.1 IDE.</li><P>
<li>Look at the generated Makefile(*unx) , Solution/workspace files(Windows) and you got it.</li>
</UL>

<P><hr>

<h3>Assemble</h3>

Now we can step forward to build the assembly. Here we are going to
build the simplest case only, which is 1 Receiver and 1 Sender. If you
are interested in CIAO you could try 1 Sender with multiple
Receiver. However, you need to change the Sender.idl to make it
<em>publishes</em> timeout event instead of <em>emits</em> event.

<UL>
<li> You need to create an XML descriptor file to describe your
    <em>deployment plan</em>, which is defined in a <EM>Deployment Plan Descriptor</EM> (.cdp).
   In this file, you need to declaratively specify how the component assembly is constructed. Specificly, you need to specify the component types, component instances, component connections, implementation artifact descriptions, and whether you want to register component instances with naming service. <P>

<li> Please make sure that the Modified_Deployment.xsd and XMI.xsd files are in the Hello/descriptors directory.
The former file could be found in $CIAO_ROOT/docs/schema directory. <P>

<li> Create the <em>NodeManagerMap.dat</em> file containing the CORBALOC IIOP address of each <code>NodeManager</code> 
     where it is running. Please refer to the existing <code>NodeManagerMap.dat</code> for details, 
     as you can see, we only specify 2 <code>NodeManagers</code>, which means these two components 
     will be installed in the different <code>NodeApplication</code> server. Please refer to the
     <em>flattened_deploymentplan.cdp</em> file to see how a deployer
    could specify the mapping between components and nodes.</li> 

Note: Creating the deployment plan descriptor is a tedious and
    error-prone job, you can download <a
    href="http://www.dre.vanderbilt.edu/cosmic">CoSMIC</a> to assist
    you in this step. <P>
</li>
</UL>

<hr>
<h3>Deploy with <A href="../../docs/releasenotes/dance.html">DAnCE</A></h3>
Finally you are ready to deploy the component-based application you have developed.
<br><br>

<UL>
  <LI> If you wish to register one or more of your component
      instances with CORBA <em> naming service</em>, then please start your naming service
      first with multicast mode first ("-m 1" option). <P>

  <LI> Go into the <em> descriptors </em> directory Start NodeManagers
      (NodeDameon) by running <code> run_NodeDaemons.pl </code> <P>
  
  <LI> Start the execution manager:
  <code>$CIAO_ROOT/DAnCE/ExecutionManager/Execution_Manager -o EM.ior -i NodeManagerMap.dat </code>
  </LI>
  
  <ul type="square"> <li> <em>NOTE</em>: As one can see, we use the "NodeManagerMap.dat" file to instruct the 
       Execution_Manager how to find the endpoint of each individual NodeManager (i.e., Node Daemon) where
       component(s) will be deployed, so this is non-standard. We plan to use Naming Service to do this in the future.
  </ul><P>

  <LI> Start the plan launcher:
  <code> $CIAO_ROOT/DAnCE/Plan_Launcher/plan_launcher -p flattened_deploymentplan.cdp -k file://EM.ior </code>
  
  <ul type="square"> <li> If you don't want to register component(s) with CORBA naming service, then you don't have to start
  your naming service, and you can use the below code to start the executor:
  
  <code> $CIAO_ROOT/DAnCE/Plan_Launcher/plan_launcher -p flattened_deploymentplan_without_ns.cdp -k file://EM.ior </code><P>
  
  After this, components should be deployed successfully. </ul><P>
  
  <LI> You can go into the <em>
      $CIAO_ROOT/DAnCE/examples/Hello/descriptor </em> directory and
      run the
      <code>$CIAO_ROOT/DAnCE/examples/Hello/Sender/starter</code> to
      start the application. Please make sure that the component IOR
      file for the Sender component (<code>Sender.ior</code>) is
      present when you run this client. <P>

  </LI>
</UL>

<hr>
<h3>More Features</h3>
Recently DAnCE is enabled with a feature called <em>Redeployment and Reconfiguration</em> (ReDaC). For more information
about how to use this feature, please refer to the ReDaC-Usage-Example.html under $CIAO_ROOT/examples/Hello/.
<br><br>

<hr>
<b>Email: </b><a href="mailto:"</a<ADDRESS>ciao-users@cse.wustl.edu</ADDRESS>
</body>
</html>

